-
Notifications
You must be signed in to change notification settings - Fork 39
feat: add systemd.maskedUnits option #361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
wow, my markdown formatter really garbled this one in the pr view. i can edit if it's hard to read! |
jfroche
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for taking the time to create this feature !
At first glance I see:
- we could simplify the test by masking an existing service started in the container like
unattended-upgrades.service - masking a unit doesn't stop the service. Should we mask the service before reloading systemd or should we stop the service explicitly ?
- system-manager deactivation should unmask the masked services
8056787 to
f2ea34c
Compare
hopefully addressed all of these in the latest push - using dbus for masking, and unattended-upgrades for testing. masked services are now added to the stop list before the mask. thank you for reviewing! |
|
All good, last nitpick before we merge: in the test we should check that the service is running before activation and stopped after activation: + with subtest("Service can be started before activation"):
+ assert machine.service("unattended-upgrades").is_running, "unattended-upgrades should be running before activation"
machine.activate()
machine.wait_for_unit("system-manager.target")
+ with subtest("Masked service is not running"):
+ assert not machine.service("unattended-upgrades").is_running, "unattended-upgrades should not be running" |
symlink units to /dev/null to prevent them from starting, useful for disabling distro-shipped units like ssh.service or unattended-upgrades.service - nix option with assertion preventing overlap with defined units - masked entries in services.json with storePath null - mask/unmask via D-Bus MaskUnitFiles/UnmaskUnitFiles - running services are explicitly stopped when masked - deactivation unmasks via D-Bus before daemon-reload - container test masks unattended-upgrades.service and verifies masking, start prevention, and unmask on deactivation closes numtide#306
f2ea34c to
ad27867
Compare
edited, thanks :) |
summary
adds
systemd.maskedUnitsoption to mask units shipped by the host distro (e.g.ssh.serviceon ubuntu). masked units are symlinked to/dev/null, preventingthem from starting manually or as a dependency.
closes #306
usage
changes
systemd.maskedUnitslist option insystemd.nixservices.jsonwithmasked: trueServiceConfig.store_pathis nowOption<StorePath>for masked unitsdesign note
went with a top-level list rather than per-service
systemd.services.<name>.mask = true— the use case is masking units you don'tdefine yourself. for units you define,
enable = falsealready works.